package com.yunwaikeji.gy_tool_library.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.yunwaikeji.gy_tool_library.R;
import com.yunwaikeji.gy_tool_library.adapter.recycler.GYRecyclerAdapter;
import com.yunwaikeji.gy_tool_library.adapter.recycler.GYViewHolder;
import com.yunwaikeji.gy_tool_library.adapter.recycler.OnItemClickListener;
import com.yunwaikeji.gy_tool_library.model.GYSelectorPwModel;
import com.yunwaikeji.gy_tool_library.info.GYRecyclerInfo;
import com.yunwaikeji.gy_tool_library.info.GYSelectorPwInfo;
import com.yunwaikeji.gy_tool_library.utils.display.GYDisplayUtils;
import com.yunwaikeji.gy_tool_library.utils.GYUtils;
import com.yunwaikeji.gy_tool_library.view.GYImageView;
import com.yunwaikeji.gy_tool_library.view.GYRelativeLayout;
import com.yunwaikeji.gy_tool_library.view.GYTextView;
import com.yunwaikeji.gy_tool_library.widget.recycler.GYRecyclerView;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class GYSelectorPw extends GYPopupWindow implements GYSelectorPwInfo, OnItemClickListener, View.OnClickListener {
    public GYSelectorPw(Context context) {
        super(context);
        init();
    }

    private GYSelectorPwAdapter gySelectorPwAdapter;
    private GYRecyclerView popRecyclerView;

    private Selector selector = Selector.SINGLE;
    private Style style = Style.NORMAL;
    private int itemPaddingLeftPx = 0;
    private int itemPaddingRightPx = 0;
    private int itemTextColor = Color.BLACK;
    private int itemTextSizePx = GYDisplayUtils.sp2px(context, 14);
    private int itemBackgroundColor = Color.WHITE;
    private int itemPressColor = Color.LTGRAY;
    private int dividerPx = 1;
    private int dividerColor = Color.LTGRAY;
    private int itemHeightPx = GYUtils.getWindowHeight(context, 0.07f);
    private Drawable checkedDrawable;
    private Drawable normalDrawable;
    //    private boolean showBottom = false;
    private int listHeightPx = WRAP_CONTENT;
    private int bottomHeightPx = GYUtils.getWindowHeight(context, 0.07f);

    private View bottomLl;
    private View bottomDividerView;
    private GYButton bottomBtn;

    private int bottomDividerPx = GYDisplayUtils.dp2px(context, 10);
    private int bottomDividerColor = Color.LTGRAY;

    private List<GYSelectorPwModel> selectorPwModelList = new ArrayList<>();
    private List<String> stringList = new ArrayList<>();

    private int checkedTextColor = WRAP_CONTENT;//选中字体颜色

    private int checkedDrawableWidthPx = WRAP_CONTENT;
    private int checkedDrawableHeightPx = WRAP_CONTENT;
    private int normalDrawableWidthPx = WRAP_CONTENT;
    private int normalDrawableHeightPx = WRAP_CONTENT;

    private BottomButtonLocation bottomButtonLocation;//底部按钮位置

    private void init() {
        getViewSet().setOrientation(LinearLayout.VERTICAL)
                .setLocation(Location.WINDOW_BOTTOM_CENTER)
                .setSizePx(GYUtils.getWindowWidth(context), WRAP_CONTENT)
                .toView()
                .getBackgroundBuilder()
                .setBackgroundColor(Color.WHITE).build();
        popRecyclerView = new GYRecyclerView(context);
        getViewSet().addViews(popRecyclerView);
        popRecyclerView.setLayoutParams(new LinearLayout.LayoutParams(GYUtils.getWindowWidth(context), 0, 1));
        gySelectorPwAdapter = new GYSelectorPwAdapter();
        popRecyclerView.getRecyclerBuilder().setRecyclerDisplayStyle(GYRecyclerInfo.DisplayStyle.VERTICAL)
                .setDividerColor(dividerColor)
                .setDividerSizePx(0)
                .build();
        popRecyclerView.setAdapter(gySelectorPwAdapter);
        gySelectorPwAdapter.setOnItemClickListener(this);
        gySelectorPwAdapter.setData(selectorPwModelList);

        bottomLl = LayoutInflater.from(context).inflate(R.layout.pw_gy_string_footer, null);
        bottomDividerView = bottomLl.findViewById(R.id.bottomDividerView);
        bottomBtn = bottomLl.findViewById(R.id.bottomBtn);
        bottomBtn.setOnClickListener(this);

        setItemTextSizeSp(14);
        setListHeightPx(WRAP_CONTENT);
        setBottomDividerPx(bottomDividerPx);
        setBottomDividerColor(bottomDividerColor);
        setBottomHeightPx(bottomHeightPx);
        setBottomBackgroundColor(bottomBackgroundColor);
        setBottomPressColor(bottomPressColor);
        setShowBottom(false);
        setDividerPx(dividerPx);
        setDividerColor(Color.LTGRAY);
        setBottomText("点击");
        setBottomTextSizeSp(14);

        setMaxSizeProportion(1f, 0.5f);

        setBottomButtonLocation(BottomButtonLocation.BOTTOM);
    }

    private List<Integer> getCheckPositionList() {
        List<Integer> checkList = new ArrayList<>();
        for (int i = 0; i < selectorPwModelList.size(); i++) {
            if (selectorPwModelList.get(i).isChecked()) {
                checkList.add(i);
            }
        }
        return checkList;
    }

    private List<String> getCheckStringList() {
        List<String> checkList = new ArrayList<>();
        for (int i = 0; i < selectorPwModelList.size(); i++) {
            GYSelectorPwModel gySelectorPWBean = selectorPwModelList.get(i);
            if (gySelectorPWBean.isChecked()) {
                checkList.add(gySelectorPWBean.getContent());
            }
        }
        return checkList;
    }

    @Override
    public void onItemClick(GYRecyclerAdapter<?, ?> adapter, View view, int position) {
        if (position < selectorPwModelList.size()) {
            final boolean checked = selectorPwModelList.get(position).isChecked();
            for (int i = 0; i < selectorPwModelList.size(); i++) {
                if (i == position) {
                    selectorPwModelList.get(i).setChecked(selector == Selector.SINGLE || !checked);
                    gySelectorPwAdapter.notifyItemChanged(i);
                } else {
                    if (selectorPwModelList.get(i).isChecked() && selector == Selector.SINGLE) {
                        selectorPwModelList.get(i).setChecked(false);
                        gySelectorPwAdapter.notifyItemChanged(i);
                    }
                }
            }
            if (onItemClickListener != null) {
                GYSelectorPwModel selectorPwModel = selectorPwModelList.get(position);
                if (!onItemClickListener.onItemClick(getCheckPositionList(), getCheckStringList(), position, selectorPwModel.getContent(), selectorPwModel.isChecked())) {
                    dismiss();
                }
            }
        }
    }

    private OnItemClickListener onItemClickListener;

    @Override
    public void onClick(View v) {
        if (onBottomClickListener != null) {
            if (!onBottomClickListener.onBottomClick(getCheckPositionList(), getCheckStringList())) {
                dismiss();
            }
        }
    }

    public void setBottomDividerView(View bottomDividerView) {
        this.bottomDividerView = bottomDividerView;
    }

    public interface OnItemClickListener {
        boolean onItemClick(List<Integer> positionList, List<String> stringList, int clickPosition, String clickString, boolean checked);
    }

    private OnBottomClickListener onBottomClickListener;

    public interface OnBottomClickListener {
        boolean onBottomClick(List<Integer> positionList, List<String> stringList);
    }

    public GYSelectorPw setStrings(String... strings) {
        return setStrings(Arrays.asList(strings));
    }

    public GYSelectorPw setStrings(List<String> stringList) {
        clear();
        return addStrings(stringList);
    }

    public GYSelectorPw addStrings(String... strings) {
        return addStrings(Arrays.asList(strings));
    }

    public GYSelectorPw addStrings(List<String> stringList) {
        this.stringList.addAll(stringList);
        selectorPwModelList.clear();
        for (String string : this.stringList) {
            GYSelectorPwModel gySelectorPwBean = new GYSelectorPwModel();
            gySelectorPwBean.setContent(string);
            gySelectorPwBean.setNormalDrawable(normalDrawable);
            gySelectorPwBean.setCheckedDrawable(checkedDrawable);
            selectorPwModelList.add(gySelectorPwBean);
        }
        return this;
    }

    public GYSelectorPw notifyDataSetChanged() {
        for (int i = 0; i < selectorPwModelList.size(); i++) {
            if (checkedStringList.contains(selectorPwModelList.get(i).getContent())) {
                selectorPwModelList.get(i).setChecked(true);
//                gySelectorPWAdapter.notifyItemChanged(i);
            }
        }
        checkedStringList.clear();
        for (Integer integer : checkedPositionList) {
            selectorPwModelList.get(integer).setChecked(true);
        }
        checkedPositionList.clear();
        gySelectorPwAdapter.notifyDataSetChanged();
        return this;
    }

    public GYSelectorPw clear() {
        stringList.clear();
        selectorPwModelList.clear();
        return notifyDataSetChanged();
    }

    private List<String> checkedStringList = new ArrayList<>();

    public GYSelectorPw setCheckedStrings(List<String> checkedStringList) {
        this.checkedStringList.clear();
        this.checkedStringList.addAll(checkedStringList);
        return this;
    }

    public GYSelectorPw setCheckedStrings(String... checkedStrings) {
        return setCheckedStrings(Arrays.asList(checkedStrings));
    }

    private List<Integer> checkedPositionList = new ArrayList<>();

    public GYSelectorPw setCheckedPositions(List<Integer> checkedPositionList) {
        this.checkedPositionList.clear();
        this.checkedPositionList.addAll(checkedPositionList);
        return this;
    }

    public GYSelectorPw setCheckedPositions(Integer... checkedPositions) {
        return setCheckedPositions(Arrays.asList(checkedPositions));
    }

    @Override
    public void show() {
        notifyDataSetChanged();
        super.show();
    }

    @Override
    public void show(View view) {
        notifyDataSetChanged();
        super.show(view);
    }

    public GYSelectorPw setBottomText(String text) {
        bottomBtn.setText(text);
        return this;
    }

    public GYSelectorPw setBottomHeightPx(int bottomHeightPx) {
        this.bottomHeightPx = bottomHeightPx;
        bottomBtn.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, bottomHeightPx));
        return this;
    }

    public GYSelectorPw setBottomHeightDp(int bottomHeightDp) {
        return setBottomHeightPx(GYDisplayUtils.dp2px(context, bottomHeightDp));
    }

    public GYSelectorPw setBottomHeightProportion(float proportion) {
        return setBottomHeightPx(GYUtils.getWindowHeight(context, proportion));
    }

    private int bottomBackgroundColor = Color.WHITE;
    private int bottomPressColor = Color.LTGRAY;

    public GYSelectorPw setBottomBackgroundColor(int bottomBackgroundColor) {
        this.bottomBackgroundColor = bottomBackgroundColor;
        bottomBtn.getBackgroundBuilder().setBackgroundColor(bottomBackgroundColor).build();
        return this;
    }

    public GYSelectorPw setBottomPressColor(int bottomPressColor) {
        this.bottomPressColor = bottomPressColor;
        bottomBtn.getBackgroundBuilder().setChangeColor(bottomPressColor).build();
        return this;
    }

    public GYSelectorPw setShowBottom(boolean showBottom) {
        bottomLl.setVisibility(showBottom ? View.VISIBLE : View.GONE);
        return this;
    }

    public GYSelectorPw setSelector(Selector selector) {
        this.selector = selector;
        return this;
    }

    public GYSelectorPw setStyle(Style style) {
        this.style = style;
        return this;
    }

    private class GYSelectorPwAdapter extends GYRecyclerAdapter<GYSelectorPwModel, GYViewHolder> {

        public GYSelectorPwAdapter() {
            super(R.layout.adapter_pw_gy_string);
        }

        @Override
        protected void convert(GYViewHolder helper, GYSelectorPwModel item) {
            GYRelativeLayout itemRL = helper.getView(R.id.itemRL);
            GYTextView gyTextView = helper.getView(R.id.contentTV);
            GYRelativeLayout.LayoutParams layoutParams = (GYRelativeLayout.LayoutParams) gyTextView.getLayoutParams();
            GYImageView gyImageView = helper.getView(R.id.checkImg);
            itemRL.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, itemHeightPx));
            itemRL.getViewSet().setPaddingPx(itemPaddingLeftPx, 0, itemPaddingRightPx, 0)
                    .toView()
                    .getBackgroundBuilder()
                    .setBackgroundColor(itemBackgroundColor)
                    .setChangeColor(itemPressColor).build();
            gyTextView.getViewSet().setText(item.getContent())
                    .setTextSizePx(itemTextSizePx)
                    .setTextColor(itemTextColor);
            if (style == Style.NORMAL) {
                layoutParams.addRule(GYRelativeLayout.CENTER_IN_PARENT);
                gyImageView.setVisibility(View.GONE);
            } else if (style == Style.CHECK) {
                layoutParams.addRule(GYRelativeLayout.CENTER_VERTICAL);
                gyImageView.setVisibility(View.VISIBLE);
                if (item.isChecked()) {
                    gyImageView.getViewSet().setSizePx(checkedDrawableWidthPx, checkedDrawableHeightPx);
                    if (checkedDrawable != null) {
                        gyImageView.getViewSet().setVisibility(View.VISIBLE);
                        gyImageView.getImageBuilder().setImageDrawable(checkedDrawable).build();
                    } else {
                        gyImageView.getViewSet().setVisibility(View.GONE);
                    }
                    int checkedTextColor1 = checkedTextColor == WRAP_CONTENT ? itemTextColor : checkedTextColor;
                    gyTextView.getViewSet().setTextColor(checkedTextColor1);
                } else {
                    gyImageView.getViewSet().setSizePx(normalDrawableWidthPx, normalDrawableHeightPx);
                    if (normalDrawable != null) {
                        gyImageView.getViewSet().setVisibility(View.VISIBLE);
                        gyImageView.getImageBuilder().setImageDrawable(normalDrawable).build();
                    } else {
                        gyImageView.getViewSet().setVisibility(View.GONE);
                    }
                }
            }
            gyTextView.setLayoutParams(layoutParams);
        }
    }

    public GYSelectorPw setBottomTextSizePx(int bottomTextSizePx) {
        bottomBtn.setTextSizePx(bottomTextSizePx);
        return this;
    }

    public GYSelectorPw setBottomTextSizeSp(int bottomTextSizeSp) {
        bottomBtn.setTextSizeSp(bottomTextSizeSp);
        return this;
    }

    private int bottomTextColor = Color.BLACK;

    public GYSelectorPw setBottomTextColor(int bottomTextColor) {
        this.bottomTextColor = bottomTextColor;
        bottomBtn.setTextColor(bottomTextColor);
        return this;
    }

    public GYSelectorPw setBottomDividerPx(int bottomDividerPx) {
        this.bottomDividerPx = bottomDividerPx;
        bottomDividerView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, bottomDividerPx));
        return this;
    }

    public GYSelectorPw setBottomDividerDp(int bottomDividerDp) {
        return setBottomDividerPx(GYDisplayUtils.dp2px(context, bottomDividerDp));
    }

    public GYSelectorPw setBottomDividerColor(int bottomDividerColor) {
        this.bottomDividerColor = bottomDividerColor;
        bottomDividerView.setBackgroundColor(bottomDividerColor);
        return this;
    }

    @SuppressLint("NewApi")
    public GYSelectorPw setNormalDrawable(int normalResId) {
        return setNormalDrawable(context.getDrawable(normalResId));
    }

    public GYSelectorPw setNormalDrawable(Drawable normalDrawable) {
        this.normalDrawable = normalDrawable;
        return this;
    }

    @SuppressLint("NewApi")
    public GYSelectorPw setCheckedDrawable(int checkedResId) {
        return setCheckedDrawable(context.getDrawable(checkedResId));
    }

    public GYSelectorPw setCheckedDrawable(Drawable checkedDrawable) {
        this.checkedDrawable = checkedDrawable;
        return this;
    }

    public GYSelectorPw setItemBackgroundColor(int itemBackgroundColor) {
        this.itemBackgroundColor = itemBackgroundColor;
        return this;
    }

    public GYSelectorPw setItemPaddingLeftDp(int itemPaddingLeftDp) {
        return setItemPaddingLeftPx(GYDisplayUtils.dp2px(context, itemPaddingLeftDp));
    }

    public GYSelectorPw setItemPaddingLeftPx(int itemPaddingLeft) {
        this.itemPaddingLeftPx = itemPaddingLeft;
        return this;
    }

    public GYSelectorPw setItemPaddingRightDp(int itemPaddingRightDp) {
        return setItemPaddingRightPx(GYDisplayUtils.dp2px(context, itemPaddingRightDp));
    }

    public GYSelectorPw setItemPaddingRightPx(int itemPaddingRightPx) {
        this.itemPaddingRightPx = itemPaddingRightPx;
        return this;
    }

    public GYSelectorPw setItemPressColor(int itemPressColor) {
        this.itemPressColor = itemPressColor;
        return this;
    }

    public GYSelectorPw setItemTextColor(int itemTextColor) {
        this.itemTextColor = itemTextColor;
        return this;
    }

    public GYSelectorPw setItemTextSizePx(int itemTextSizePx) {
        this.itemTextSizePx = itemTextSizePx;
        return this;
    }

    public GYSelectorPw setItemTextSizeSp(int itemTextSizeSp) {
        return setItemTextSizePx(GYDisplayUtils.sp2px(context, itemTextSizeSp));
    }

    public GYSelectorPw setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
        return this;
    }

    public GYSelectorPw setOnBottomClickListener(OnBottomClickListener onBottomClickListener) {
        this.onBottomClickListener = onBottomClickListener;
        return this;
    }

    public GYSelectorPw setDividerDp(int spacingDp) {
        return setDividerPx(GYDisplayUtils.dp2px(context, spacingDp));
    }

    public GYSelectorPw setDividerPx(int dividerPx) {
        this.dividerPx = dividerPx;
        popRecyclerView.getRecyclerBuilder().setDividerSizePx(dividerPx)
                .build();
        return this;
    }

    public GYSelectorPw setDividerColor(int dividerColor) {
        this.dividerColor = dividerColor;
        popRecyclerView
                .getRecyclerBuilder()
                .setDividerColor(dividerColor)
                .build();
        return this;
    }

    public GYSelectorPw setMaxSizeProportion(float maxWidthProportion, float maxHeightProportion) {
        getViewSet().setMaxSizeProportion(maxWidthProportion, maxHeightProportion);
        return this;
    }

    public GYSelectorPw setListHeightPx(int listHeightPx) {
        this.listHeightPx = listHeightPx;
        popRecyclerView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, this.listHeightPx, 1));
        return this;
    }

    public GYSelectorPw setListHeightDp(int listHeightDp) {
        return setListHeightPx(GYDisplayUtils.dp2px(context, listHeightDp));
    }

    public GYSelectorPw setListHeightProportion(float proportion) {
        return setListHeightPx(GYUtils.getWindowHeight(context, proportion));
    }

    public GYSelectorPw setItemHeightPx(int itemHeightPx) {
        this.itemHeightPx = itemHeightPx;
        return this;
    }

    public GYSelectorPw setItemHeightDp(int itemHeightDp) {
        return setItemHeightPx(GYDisplayUtils.dp2px(context, itemHeightDp));
    }

    public GYSelectorPw setItemHeightProportion(float proportion) {
        return setItemHeightPx(GYUtils.getWindowHeight(context, proportion));
    }

    public GYSelectorPw setCheckedTextColor(int checkedTextColor) {
        this.checkedTextColor = checkedTextColor;
        return this;
    }

    public GYSelectorPw setCheckedDrawableSizePx(int checkedDrawableWidthPx, int checkedDrawableHeightPx) {
        this.checkedDrawableWidthPx = checkedDrawableWidthPx;
        this.checkedDrawableHeightPx = checkedDrawableHeightPx;
        return this;
    }

    public GYSelectorPw setCheckedDrawableSizeDp(int checkedDrawableWidthDp, int checkedDrawableHeightDp) {
        return setCheckedDrawableSizePx(GYDisplayUtils.dp2px(context, checkedDrawableWidthDp), GYDisplayUtils.dp2px(context, checkedDrawableHeightDp));
    }

    public GYSelectorPw setCheckedDrawableWidthPx(int checkedDrawableWidthPx) {
        return setCheckedDrawableSizePx(checkedDrawableWidthPx, checkedDrawableHeightPx);
    }

    public GYSelectorPw setCheckedDrawableWidthDp(int checkedDrawableWidthDp) {
        return setCheckedDrawableWidthPx(GYDisplayUtils.dp2px(context, checkedDrawableWidthDp));
    }

    public GYSelectorPw setCheckedDrawableHeightPx(int checkedDrawableHeightPx) {
        return setCheckedDrawableSizePx(checkedDrawableWidthPx, checkedDrawableHeightPx);
    }

    public GYSelectorPw setCheckedDrawableHeightDp(int checkedDrawableHeightDp) {
        return setCheckedDrawableHeightPx(GYDisplayUtils.dp2px(context, checkedDrawableHeightDp));
    }

    public GYSelectorPw setNormalDrawableSizePx(int normalDrawableWidthPx, int normalDrawableHeightPx) {
        this.normalDrawableWidthPx = normalDrawableWidthPx;
        this.normalDrawableHeightPx = normalDrawableHeightPx;
        return this;
    }

    public GYSelectorPw setNormalDrawableSizeDp(int normalDrawableWidthDp, int normalDrawableHeightDp) {
        return setNormalDrawableSizePx(GYDisplayUtils.dp2px(context, normalDrawableWidthDp), GYDisplayUtils.dp2px(context, normalDrawableHeightDp));
    }

    public GYSelectorPw setNormalDrawableWidthPx(int normalDrawableWidthPx) {
        return setNormalDrawableSizePx(normalDrawableWidthPx, normalDrawableHeightPx);
    }

    public GYSelectorPw setNormalDrawableWidthDp(int normalDrawableWidthDp) {
        return setNormalDrawableWidthPx(GYDisplayUtils.dp2px(context, normalDrawableWidthDp));
    }

    public GYSelectorPw setNormalDrawableHeightPx(int normalDrawableHeightPx) {
        return setNormalDrawableSizePx(normalDrawableWidthPx, normalDrawableHeightPx);
    }

    public GYSelectorPw setNormalDrawableHeightDp(int normalDrawableHeightDp) {
        return setNormalDrawableHeightPx(GYDisplayUtils.dp2px(context, normalDrawableHeightDp));
    }

    public GYSelectorPw setDrawableSizePx(int drawableWidthPx, int drawableHeightPx) {
        setCheckedDrawableSizePx(drawableWidthPx, drawableHeightPx);
        setNormalDrawableSizePx(drawableWidthPx, drawableHeightPx);
        return this;
    }

    public GYSelectorPw setDrawableSizeDp(int drawableWidthDp, int drawableHeightDp) {
        return setDrawableSizePx(GYDisplayUtils.dp2px(context, drawableWidthDp), GYDisplayUtils.dp2px(context, drawableHeightDp));
    }

    public GYSelectorPw setDrawableWidthPx(int drawableWidthPx) {
        setCheckedDrawableWidthPx(drawableWidthPx);
        setNormalDrawableWidthPx(drawableWidthPx);
        return this;
    }

    public GYSelectorPw setDrawableWidthDp(int drawableWidthDp) {
        return setDrawableWidthPx(GYDisplayUtils.dp2px(context, drawableWidthDp));
    }

    public GYSelectorPw setDrawableHeightPx(int drawableHeightPx) {
        setCheckedDrawableHeightPx(drawableHeightPx);
        setNormalDrawableHeightPx(drawableHeightPx);
        return this;
    }

    public GYSelectorPw setDrawableHeightDp(int drawableHeightDp) {
        return setDrawableHeightPx(GYDisplayUtils.dp2px(context, drawableHeightDp));
    }

    public GYSelectorPw setBottomButtonLocation(BottomButtonLocation bottomButtonLocation) {
        this.bottomButtonLocation = bottomButtonLocation;
        getViewSet().removeView(bottomLl);
        gySelectorPwAdapter.removeFooterView(bottomLl);
        if (bottomButtonLocation == BottomButtonLocation.BOTTOM) {
            getViewSet().addViews(bottomLl);
        } else if (bottomButtonLocation == BottomButtonLocation.FOOTER) {
            gySelectorPwAdapter.addFooterView(bottomLl);
        }
        return this;
    }

    public BottomButtonLocation getBottomButtonLocation() {
        return bottomButtonLocation;
    }
}
